<%
 '
 ' Copyright 2007 Liu, Xiaokang <4341322@gmail.com>
 ' Blog <http://www.ioio.name/>
 ' 
 ' This file is part of JOS(Judge Online System).
 ' You can see this project at <http://code.google.com/p/judgeonline/>
 ' 
 ' JOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 ' published by the Free Software Foundation; either revision 3 of the License, or (at your option) any later revision.
 ' 
 ' JOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 ' 
 ' You should have received a copy of the GNU General Public License along with JOS. if not, see
 ' <http://www.gnu.org/licenses/>.
 '
%>
<!--#include file="Config.asp"-->
<%
Dim CompilerPath,DatabasePath,ProblemPath,ProblemTmpPath,SolutionPath,WwwrootPath,TesterPath
	CompilerPath	=	ServerPath+"Compiler\"
	DatabasePath	=	ServerPath+"Database\"
	ProblemPath	=	ServerPath+"Problem\"
	ProblemTmpPath	=	ServerPath+"ProbTmp\"
	SolutionPath	=	ServerPath+"Solution\"
	WwwrootPath	=	ServerPath+"Wwwroot\"
	TesterPath	= 	ServerPath + "Tester\"
	
Dim CookiesName
CookiesName="coco"
	
Dim conn,connstr
Set conn=Server.CreateObject("ADODB.Connection")
connstr = "Provider=SQLOLEDB;Data Source="&DataHost&";Initial Catalog="&DataName&";User Id="&DataUser&";Password="&DataPass
	
Function IsLogin()
If Session.SessionID=Request.Cookies(CookiesName)("CookiesID") Then
	IsLogin=True
Else
	IsLogin=False
End If
End function
  
Function IsAdmin()
If Request.Cookies(CookiesName)("Permission")=1 Then
	IsAdmin=True
Else
	IsAdmin=False
End If
End function
  
Function GetUsername()
GetUsername=Request.Cookies(CookiesName)("Username")
End function

Function GetUid()
GetUid=Request.Cookies(CookiesName)("Uid")
End function
  
Function GetSystemGroupCode()
  Dim Uid,Password,Rs
    Uid= Session("Uid")
    Password= Session("Password")   
	If Uid<>""and Password<>"" Then 
	conn.Open connstr
	set Rs=server.CreateObject("ADODB.Recordset")
	Rs.Open "select * from Members Where Uid='"&Uid&"' and Password='"&Password&"'",conn,1,3
	
	If Rs.BOF Or Rs.EOF Then
		GetSystemGroupCode=0
	Else
		GetSystemGroupCode=Rs("Admin")
	End If	
	rs.Close
	set rs=Nothing
	conn.Close
	Else
		GetSystemGroupCode=0
	End If
End function

Function CheckEmail(strEmail)
 Dim re
 Set re = New RegExp
 re.Pattern ="^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"
 re.IgnoreCase = True
 CheckEmail = re.Test(strEmail)
 Set re=Nothing
End Function
%>